package com.wangxinenpu.springbootdemo.controller;

import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wangxinenpu.springbootdemo.dataobject.dto.system.SystemDto;
import com.wangxinenpu.springbootdemo.dataobject.vo.system.SystemVo;
import com.wangxinenpu.springbootdemo.service.SystemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping ( "/system" )
@AllArgsConstructor
@Api ( value = "系统管理", tags = "系统管理" )
@Slf4j
public class SystemController {

	private final SystemService systemService;

	@PostMapping ( "/pageList" )
	@ApiOperation ( value = "分页列表", notes = "分页列表" )
	public R < Page < SystemVo > > pageList( @RequestBody SystemDto dto ) {
		return systemService.pageList( dto );
	}

	@PostMapping ( "/savaOrUpdate" )
	@ApiOperation ( value = "新增/编辑", notes = "新增/编辑" )
	public R < Boolean > savaOrUpdate( @RequestBody @Validated SystemVo dto ) {
		return systemService.savaOrUpdate( dto );
	}

	@PostMapping ( "/delete" )
	@ApiOperation ( value = "删除/批量删除", notes = "删除/批量删除" )
	public R < Boolean > delete( @RequestBody List < String > ids ) {
		return systemService.delete( ids );
	}

	@GetMapping ( "detail" )
	@ApiOperation ( value = "详情", tags = "详情" )
	public R < SystemVo > detail( @RequestParam String id ) {
		return systemService.detail( id );
	}


}
